# 导包
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
# 1.导入鼠标操作类
from selenium.webdriver.common.action_chains import ActionChains
# 获取浏览器驱动
driver = webdriver.Firefox()
# 打开测试的网址
url = 'file:///C:/Users/tedu/Desktop/NSD2407/html/registerA.html'
driver.get(url)
# 2.创建鼠标操作对象，传递浏览器驱动
action = ActionChains(driver)
# 3.在用户名文本框元素执行右击
username = driver.find_element(By.CSS_SELECTOR, '#userA')
# perform 执行以上的操作
action.context_click(username).perform()
# 在用户名上输入内容
sleep(3)
username.send_keys('admin')
# 4.在用户名上双击
action.double_click(username).perform()
# 5.鼠标悬停
btn = driver.find_element(By.CSS_SELECTOR, '[value="注册A"]')
sleep(3)
action.move_to_element(btn).perform()


# 停顿3秒，关闭浏览器
sleep(3)
driver.quit()